package com.ruoyi.system.controller;

import java.util.List;
import java.util.Map;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IInteractionsService;

/**
 * 交互数据Controller
 * 
 * @author ruoyi
 * @date 2025-09-27
 */
@RestController
@RequestMapping("/system/interactions")
public class InteractionsController extends BaseController
{
    @Autowired
    private IInteractionsService interactionsService;

    /**
     * 获取今日统计数据
     */
    @PreAuthorize("@ss.hasPermi('system:notifications:list')")
    @GetMapping("/today-stats")
    public AjaxResult getTodayStats()
    {
        Map<String, Object> stats = interactionsService.getTodayStats();
        return AjaxResult.success(stats);
    }

    /**
     * 获取最新点赞数据
     */
    @PreAuthorize("@ss.hasPermi('system:notifications:list')")
    @GetMapping("/recent-likes")
    public AjaxResult getRecentLikes()
    {
        List<Map<String, Object>> likes = interactionsService.getRecentLikes();
        return AjaxResult.success(likes);
    }

    /**
     * 获取最新收藏数据
     */
    @PreAuthorize("@ss.hasPermi('system:notifications:list')")
    @GetMapping("/recent-collects")
    public AjaxResult getRecentCollects()
    {
        List<Map<String, Object>> collects = interactionsService.getRecentCollects();
        return AjaxResult.success(collects);
    }

    /**
     * 获取最新关注数据
     */
    @PreAuthorize("@ss.hasPermi('system:notifications:list')")
    @GetMapping("/recent-follows")
    public AjaxResult getRecentFollows()
    {
        List<Map<String, Object>> follows = interactionsService.getRecentFollows();
        return AjaxResult.success(follows);
    }

    /**
     * 获取最新评论数据
     */
    @PreAuthorize("@ss.hasPermi('system:notifications:list')")
    @GetMapping("/recent-comments")
    public AjaxResult getRecentComments()
    {
        List<Map<String, Object>> comments = interactionsService.getRecentComments();
        return AjaxResult.success(comments);
    }

    /**
     * 禁用评论
     */
    @PreAuthorize("@ss.hasPermi('system:comments:edit')")
    @Log(title = "评论管理", businessType = BusinessType.UPDATE)
    @PutMapping("/disable-comment/{commentId}")
    public AjaxResult disableComment(@PathVariable Long commentId)
    {
        return toAjax(interactionsService.disableComment(commentId));
    }

    /**
     * 启用评论
     */
    @PreAuthorize("@ss.hasPermi('system:comments:edit')")
    @Log(title = "评论管理", businessType = BusinessType.UPDATE)
    @PutMapping("/enable-comment/{commentId}")
    public AjaxResult enableComment(@PathVariable Long commentId)
    {
        return toAjax(interactionsService.enableComment(commentId));
    }
}
